//
//  ViewController.m
//  scroll
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIScrollViewDelegate>

@property (strong, nonatomic) IBOutlet UIScrollView *scrollview;
@property (strong, nonatomic) IBOutlet UIPageControl *page;
@property (nonatomic,weak) UIImageView *imgView;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIView *view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 320)];
    view1.backgroundColor = [UIColor redColor];
    UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 200, 320, 320)];
//    [scrollview addSubview:view1];
    UIImage *image=[UIImage imageNamed:@"1"];
     UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    [scrollview addSubview:imageView];
  scrollview.contentSize=CGSizeMake(320*2, 0);

    scrollview.backgroundColor = [UIColor blackColor];
    [self.view addSubview:scrollview];
    
    imageView.tag = 101;
    // 设置最大缩放几倍
    scrollview.maximumZoomScale = 2;
    scrollview.minimumZoomScale = 0.2;
    
    // 设置代理人,谁为scorllView提供事件处理
    scrollview.delegate = self;
    
}

- (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {

    return self.imgView;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
